package cn.tedu.Controller;

import cn.tedu.sp1.Service.UserService;
import cn.tedu.sp1.Web.Util.JsonResult;
import cn.tedu.sp1.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    private UserService userService ;

    @GetMapping("/{userId}")
    public JsonResult<User> getUser (@PathVariable  Integer userId){
        User u  = userService.getUser(userId);
        return JsonResult.ok().data(u);
    }
    @GetMapping("/{userId}score")
    public JsonResult<?> addScore(@PathVariable Integer userId , Integer score){
        userService.addScore(userId,score);
        return JsonResult.ok().msg("增加成功");
    }
}
